<template>
	<view class="box">
		<u-alert title="默认交易密码为: 123456" type = "warning"></u-alert>
		<view class="inp">
	{{$t('idSafe.changeLoginP.originalP')}}:	<input type="number" v-model="oldpass" :placeholder="$t('idSafe.changeDealP.originalP')">
		</view>
		<view class="inps">
			{{$t('idSafe.changeLoginP.newP')}}:	<input type="number" v-model="newpass1" :placeholder="$t('idSafe.changeDealP.newP')">
		</view>
		<view class="xian"></view>
		<view class="inps">
			{{$t('idSafe.changeLoginP.sureNewP')}}:	<input type="password" v-model="newpass2" :placeholder="$t('idSafe.changeLoginP.inpSureNewP')">
		</view>
		<button type="default" @click="commbit">{{$t('idSafe.changeLoginP.sure')}}</button>
	</view>
</template>

<script>
	import api from '../../common/api.js'
	export default {
		data() {
			return {
				oldpass:'',
				newpass1:'',
				newpass2:'',
				token:''
			}
		},
		methods: {
			commbit(){
				var {oldpass,newpass1,newpass2}=this;
				if(oldpass&&newpass1&&newpass2){
					if(newpass1==newpass2){
						if(newpass1.length>5 && newpass2.length>5){
							this.$api.sendRequest({
									url: api.CHANGEPaywd,
									data: {
										oldpaypwd:oldpass,
										newpaypwd:newpass2
									},
									success: res => {
										console.log(res);
										uni.showToast({
											title:res.msg,
											icon:'none'
										})
									}
								});
							
						}else{
							uni.showToast({
								title:'密码不能少于6位',
								icon:'none'
							})
						}
						
					}else{
						uni.showToast({
							title:'两次新密码不一样',
							icon:'none'
						})
					}
				}else{
					uni.showToast({
						title:'请补充完整信息',
						icon:'none'
					})
				}
			}
		},
		created() {
			uni.getStorage({
				key:'token',
				success:res=>{
					console.log(res.data);
					this.token=res.data
				}
			})
		}
	}
</script>
<style>
	page{
		background-color: #F3F3F3;
	}
</style>
<style scoped>
	.box{
		/* width: 94.6%; */
		height: 90vh;
		font-size: 1em;
		position: relative;
	}
.inp{
	width: 94.6%;
	height: 100rpx;
	display: flex;
	background-color: #FFFFFF;
	line-height: 100rpx;
	margin-bottom: 40rpx;
	padding-left: 40rpx;
	
}
.xian{
	width: 94.6%;
	height: 3rpx;
}
.inps{
	width: 94.6%;
	height: 100rpx;
	display: flex;
	padding-left: 40rpx;
	background-color: #FFFFFF;
	line-height: 100rpx;
	margin-bottom: 4rpx;
	font-size: .8em;
}
input{
	width: 500rpx;
	height: 100rpx;
	padding-left: 40rpx;
	color: #000000;
}
button{
	width: 90%;
	position: absolute;
	background-color: #006bef;
	color: #FFFFFF;
	bottom: 5vh;
	left: calc(50% - 45%);
	}
</style>

